home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 2000 October
/
Software of the Month - Ultimate Collection Shareware 277.iso
/
pc
/
PROGRAMS
/
UTILITY
/
WINLINUX
/
DATA1.CAB
/
etc_-_Configuration_Files
/
RC.D
/
RC.6
< prev
Wrap
Text File
|
1999-09-17
|
3KB
|
119 lines
#! /bin/sh
#
# rc.6 This file is executed by init when it goes into runlevel
# 0 (halt) or runlevel 6 (reboot). It kills all processes,
# unmounts file systems and then either halts or reboots.
#
# Version: @(#)/etc/rc.d/rc.6 1.50 1994-01-15
#
# Author: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
# Modified by: Patrick J. Volkerding, <volkerdi@ftp.cdrom.com>
#
# Set the path.
PATH=/sbin:/etc:/bin:/usr/bin
# Set linefeed mode to avoid staircase effect.
stty onlcr
echo "Running shutdown script $0:"
# Find out how we were called.
case "$0" in
*0)
command="halt"
;;
*6)
command=reboot
;;
*)
echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
exit 1
;;
esac
# Kill all processes.
# INIT is supposed to handle this entirely now, but this didn't always
# work correctly without this second pass at killing off the processes.
# Since INIT already notified the user that processes were being killed,
# we'll avoid echoing this info this time around.
if [ "$1" != "fast" ]; then # shutdown did not already kill all processes
killall5 -15
sleep 5
killall5 -9
fi
# Try to turn off quota and accounting.
if [ -x /usr/sbin/quotaoff ]
then
echo "Turning off quota."
/usr/sbin/quotaoff -a
fi
if [ -x /sbin/accton ]
then
echo "Turning off accounting."
/sbin/accton
fi
# Before unmounting file systems write a reboot or halt record to wtmp.
$command -w
# Unmount any remote filesystems:
echo "Unmounting remote filesystems."
umount -a -tnfs
## WinLinux must check if this was a cold boot and reset autoexec and
## config files in that case
CONFIG="/DOS/config.sys"
CONFIGWOS="/DOS/config.wos"
AEXEC="/DOS/autoexec.bat"
AEXECWOS="/DOS/autoexec.wos"
KEYWORD="DOS"
PAR="SINGLE"
TEMPFILE="/tmp/autoexec.bat.$$"
if [ -e "$CONFIG" ] ; then
if grep -i $KEYWORD $CONFIG | grep -i $PAR > /dev/null ; then
if [ -e $CONFIGWOS -a -e $AEXECWOS ] ; then
grep -vi 'LINUX.BAT' $AEXEC > $TEMPFILE
rm -f $AEXEC
cp $TEMPFILE $AEXEC > /dev/null 2>&1
rm -f $TEMPFILE
fi
fi
fi
# Turn off swap, then unmount local file systems.
echo "Turning off swap."
swapoff -a
echo "Unmounting local file systems."
# Don't remount UMSDOS root volumes:
if [ ! "`mount | head -1 | cut -d ' ' -f 5`" = "umsdos" ]; then
umount -a -tnonfs
echo "Remounting root filesystem read-only."
mount -n -o remount,ro /
else
umount -a -tnonfs -tnoumsdos
touch /clean
fi
# This never hurts:
sync
# See if this is a powerfail situation.
if [ -f /etc/power_is_failing ]; then
echo "Turning off UPS, bye."
/sbin/powerd -q
exit 1
fi
# Now halt (poweroff with APM kernels) or reboot.
if [ "$command" = "reboot" ]; then
echo ""
echo "The system is being restarted..."
reboot -f
else
echo ""
echo "You can turn off your computer now."
halt -f -p
fi